﻿using Microsoft.Xaml.Behaviors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace HotelManager.Common.Behaviors
{
    public class ClearTextBehavior:Behavior<Button>
    {
        public TextBox Target
        {
            get { return (TextBox)GetValue(TargetProperty); }
            set { SetValue(TargetProperty, value); }
        }
        public static readonly DependencyProperty TargetProperty = DependencyProperty.Register("Target", typeof(TextBox), typeof(ClearTextBehavior), new PropertyMetadata(null));
        protected override void OnAttached()
        {
            AssociatedObject.Click += ButtonClick;
        }
        protected override void OnDetaching()
        {
            AssociatedObject.Click -= ButtonClick;
        }
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
           Target?.Clear();
        }
    }
}
